package com.zzc.emotisenseclassroom.dbservice.user.impl;

import com.zzc.baseRepository.componet.CommonSqlBuider;
import com.zzc.baseRepository.componet.WhereConditionEnum;
import com.zzc.baseRepository.componet.Wheres;
import com.zzc.baseRepository.componet.interfaces.BaseDao;
import com.zzc.baseRepository.componet.interfaces.BaseDbService;
import com.zzc.emotisenseclassroom.dao.user.ClassDao;
import com.zzc.emotisenseclassroom.dbservice.user.ClassDbService;
import com.zzc.emotisenseclassroom.dto.user.ClassDTO;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * Copyright Zzc
 * FileName: ClassDbServiceImpl
 * Author:   Zzc
 * Date:     2024/4/2718:15
 * Description:班级 db service层实现类
 * hISTORY:
 * <author>  <time>     <version>    <desc>
 * 作者姓名   修改时间       版本号       描述
 * Zzc                   1.0.0
 */
@Service
public class ClassDbServiceImpl extends BaseDbService<ClassDao> implements ClassDbService {

    @Override
    public List<ClassDTO> getClassInfoList(Long schoolId) {
        if (schoolId == null){
            return Collections.emptyList();
        }

        CommonSqlBuider commonSqlBuider = new CommonSqlBuider();
        commonSqlBuider.selectFrom(ClassDao.class);
        commonSqlBuider.select(Arrays.asList(ClassDao.CLASS_ID, ClassDao.CLASS_NAME));
        Wheres where = commonSqlBuider.where();
        where.andWhere(ClassDao.SCHOOL_ID, WhereConditionEnum.EQ, String.valueOf(schoolId));

        return baseDao.list(commonSqlBuider, ClassDTO.class);
    }
}
